#import "Packet.h"

@implementation Packet

-(id)init{
	[super init];
	writer=[SBJsonWriter new];
	return self;
}

-(void)initWithAction:(NSString *)act andContent:(id)dict{
	action=act;
	if(dict==nil)
		content=[NSNull null];
	else
		content=dict;
}

-(id)proxyForJson {
	NSDate *now=[NSDate date];
	NSNumber *intv=[NSNumber numberWithUnsignedLongLong:((long long)([now timeIntervalSince1970]*1000))];
	return [NSDictionary dictionaryWithObjectsAndKeys:content,@"content",action,@"action",intv,@"time",nil];
}

-(void)dealloc{
	[writer release];
	[action release];
	[content release];
	[super dealloc];
}

@end
